package com.isscollage.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.isscollage.dao.TicketDao;
import com.isscollage.entity.Ticket;
import com.isscollage.search.TicketSearch;
import com.isscollage.service.TicketService;
@Service
public class TicketServiceImpl implements TicketService {
	
	@Autowired
	private TicketDao ticketDao;
	
	@Override
	public List<Ticket> searchTicketsByCon(TicketSearch search) {
		// TODO Auto-generated method stub
		List<Ticket> list=ticketDao.searchTicketsByCon(search);
		return list;
	}
	
	@Override
	public List<Ticket> searchAll() {
		// TODO Auto-generated method stub
		return ticketDao.searchAll();
	}

	@Override
	public boolean insert(Ticket ticket) {
		// TODO Auto-generated method stub
		if(ticket.getTicketId()!=null){
			ticket.setTicketId(null);
		}
		ticket.setCreateTime(new Date());
		boolean flag=ticketDao.insert(ticket);
		return flag;
	}

	@Override
	public Ticket getTicketById(Integer ticketId) {
		// TODO Auto-generated method stub
		Ticket ticket=ticketDao.getTicketById(ticketId);
		return ticket;
	}

	@Override
	public boolean update(Ticket ticket) {
		// TODO Auto-generated method stub
		if(ticket!=null && ticket.getTicketId()!=null ){
			return ticketDao.update(ticket);			
		}
		return false;
	}

	@Override
	public boolean deleteAll(Integer[] ids) {
		// TODO Auto-generated method stub
		boolean flag=false;
		if(ids!=null && ids.length>0){
			flag=ticketDao.deleteAll(ids);
		}
		return flag;
	}



}
